from django.views import generic
from django.shortcuts import render
from .models import Book, Author

class BookListView(generic.ListView):
    model = Book
    paginate_by = 10

class BookDetailView(generic.DetailView):
    model = Book

class AuthorListView(generic.ListView):
    model = Author
    paginate_by = 10

class AuthorDetailView(generic.DetailView):
    model = Author

def index(request):
    num_books = Book.objects.count()
    num_authors = Author.objects.count()

    return render(request, 'index.html', context={
        'num_books': num_books,
        'num_authors': num_authors,
    })
